<?$this->load->view('admin/header');?>
<!-- Content Area -->
<div id="middlepart">
    <!-- Left column -->
    <div id="leftcolumn">

        <h1>Dashboard</h1>

        <?if (!$this->mdl_categories->system_check()) {?>
        <div class="notes"><span>System Status Notification</span>
            <p>You must have at least one category before you can create a post. <?=anchor('admin_categories/form', 'Click here');?> to create a category.</p>
        </div>
        <?}?>

        <div id="container-1">
            <ul>
                <li><a href="#fragment-7"><span>Recent Posts</span></a></li>
                <li><a href="#fragment-8"><span>Recent Comments</span></a></li>
                <?if($this->session->userdata('user_type_id') == 1 OR $this->session->userdata('user_type_id') == 2) {?>
                <li><a href="#fragment-9"><span>New Users</span></a></li>
                <?}?>
                <li><a href="#fragment-10"><span>Site Stats</span></a></li>
            </ul>

            <div id="fragment-7">
                <!-- Tables 1 -->
                <table border="0" cellspacing="0" cellpadding="0" width="100%">
                    <thead>
                        <tr>
                            <th>Date</th>
                            <th>Title</th>
                            <th>Author</th>
                            <th>Views</th>
                            <th>Status</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                        <?foreach ($this->mdl_posts->get(array('limit'=>10, 'order_by'=>'date DESC')) as $post) {?>
                        <tr>
                            <td><?=date('Y-m-d', $post->date);?></td>
                            <td><?=$post->title;?></td>
                            <td><?=$post->display_name;?></td>
                            <td></td>
                            <td></td>
                            <td width="125px">
                                    <?=anchor('admin_posts/form/post_id/' . $post->post_id, 'edit', array('class'=>'edit'));?>
                                    <?=anchor('admin_posts/delete/post_id/' . $post->post_id, 'delete', array('class'=>'delete', 'onclick'=>$this->inktype->verify_delete()));?>
                            </td>
                        </tr>
                        <?}?>
                    </tbody>
                </table>
                <!-- Tables 1 -->
            </div>
            <div id="fragment-8">
                <!-- Tables 1 -->
                <table border="0" cellspacing="0" cellpadding="0" width="100%">
                    <thead>
                        <tr>
                            <th>Date</th>
                            <th>Author</th>
                            <th>Post Title</th>
                            <th>Comment</th>
                            <?if($this->session->userdata('user_type_id') == 1 OR $this->session->userdata('user_type_id') == 2) {?>
                            <th></th>
                            <?}?>
                        </tr>
                    </thead>
                    <tbody>
                        <?foreach ($this->mdl_comments->get(array('limit'=>10)) as $comment) {?>
                        <tr>
                            <td><?=$this->inktype->format_date($comment->comment_date, 2);?></td>
                            <td><?=$comment->display_name;?></td>
                            <td><?=$comment->title;?></td>
                            <td><?=character_limiter($comment->comment, 125);?></td>
                                <?if($this->session->userdata('user_type_id') == 1 OR $this->session->userdata('user_type_id') == 2) {?>
                            <td width="125px">
                                        <?=anchor('admin_comments/form/comment_id/' . $comment->comment_id, 'edit', array('class'=>'edit'));?>
                                        <?=anchor('admin_comments/delete/comment_id/' . $comment->comment_id, 'delete', array('class'=>'delete', 'onclick'=>$this->inktype->verify_delete()));?>
                            </td>
                                <?}?>
                        </tr>
                        <?}?>
                    </tbody>
                </table>
                <!-- Tables 1 -->
            </div>

            <?if($this->session->userdata('user_type_id') == 1 OR $this->session->userdata('user_type_id') == 2) {?>
            <div id="fragment-9">
                <!-- Tables 1 -->
                <table border="0" cellspacing="0" cellpadding="0" width="100%">
                    <thead>
                        <tr>
                            <th>Date Registered</th>
                            <th>Display Name</th>
                            <th>Email Address</th>
                            <th>Website</th>
                            <th></th>
                        </tr>
                    </thead>
                    <tbody>
                            <?foreach ($this->mdl_users->get(array('limit'=>10, 'order_by'=>'date_registered DESC')) as $user) {?>
                        <tr>
                            <td><?=date('Y-m-d', $user->date_registered);?></td>
                            <td><?=$user->display_name;?></td>
                            <td><?=auto_link($user->email_address);?></td>
                            <td><?=auto_link($user->website_url);?></td>
                            <td width="125px">
                                        <?=anchor('admin_users/form/user_id/' . $user->user_id, 'edit', array('class'=>'edit'));?>
                                        <?=anchor('admin_users/delete/user_id/' . $user->user_id, 'delete', array('class'=>'delete', 'onclick'=>$this->inktype->verify_delete()));?>
                            </td>
                        </tr>
                            <?}?>
                    </tbody>
                </table>
                <!-- Tables 1 -->
            </div>
            <?}?>

            <div id="fragment-10">

                <table>
                    <tr>
                        <td>Site URL: </td>
                        <td><?=$this->session->userdata('current_site_url');?></td>
                    </tr>
                    <tr>
                        <td>Number of Posts: </td>
                        <td><?=$this->mdl_posts->get_num_posts();?></td>
                    </tr>
                    <tr>
                        <td>Number of Registered Users: </td>
                        <td><?=$this->mdl_users->get_num_users();?></td>
                    </tr>
                    <tr>
                        <td>Number of Comments: </td>
                        <td><?=$this->mdl_comments->get_num_comments();?></td>
                    </tr>
                </table>

            </div>

        </div>

    </div>
    <!-- Left Column -->

    <!-- Right Column -->
    <?$this->load->view('admin/index_side_box');?>
    <!-- Notes / Articles Box -->
</div>
<!-- Content -->

<?$this->load->view('admin/footer');?>